<%-- 
    Document   : c_out.jsp
    Created on : 2012-12-9, 19:44:41
    Author     : Administrator
--%>

<%@page contentType="text/html"  import="com.hsp.domain.*" pageEncoding="UTF-8"%>
<!--引入标签库标签-->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
    </head>
    <body>

        //如果我们的域对象中有相同的属性，那么c:out的优先级是pageContext > request > session >application
        <%            //request.setAttribute("abc", "你好1");
            //session.setAttribute("abc", "你好2");
            //application.setAttribute("abc", "你好3");
            //pageContext.setAttribute("abc", "你好4");

            User u = new User();
            u.setName("小明");
            u.setAge("30");
            request.setAttribute("user1", u);
        %>

        <c:out value = "hello world"></c:out>

        <h1>如何输出request/session/application/pageContext域对象的数据</h1>
        <c:out value = "${abc}" default="没有值"></c:out>

        <h1>如何输出对象的值</h1>
        <c:out value="${user1.name}"></c:out>
        <c:out value="${user1.age}"></c:out>
    </body>
</html>
